def is_prime(num):
    if num < 2:
        return False
    for i in range(2, int(num**0.5) + 1):
        if num % i == 0:
            return False
        return True
def closest_prime_number(word1, word2, word3):
    numbers = {'zero': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9}
    number = numbers.get(word1, -1)*100 + numbers.get(word2, -1)*10 + numbers.get(word3, -1)
    if 100 <= number <= 999 and is_prime(number):
        print(number)
    else:
            print("Wrong input")
word1, word2, word3 = input().split()
closest_prime_number(word1, word2, word3)
  
                
